﻿namespace Shanda.DevFx.Security.Web.Pages
{
    using Shanda.DevFx.Security.Web;
    using Shanda.DevFx.Utils;
    using System;
    using System.Web;
    using System.Web.UI.WebControls;

    public class SystemPage : Shanda.DevFx.Security.Web.BasePage
    {
        protected LinkButton btnShutdown;
        protected Label lblMessage;

        private void btnShutdown_Click(object sender, EventArgs e)
        {
            try
            {
                HttpRuntime.UnloadAppDomain();
            }
            catch (Exception exception)
            {
                this.lblMessage.set_Text("重启失败：" + exception.Message);
            }
            WebHelper.ShowMessage("正在重启，请稍候 ......", "window.location.href='../'", true, false);
        }

        private void InitializeComponent()
        {
            this.btnShutdown.add_Click(new EventHandler(this.btnShutdown_Click));
            base.add_Load(new EventHandler(this.Page_Load));
        }

        protected override void OnInit(EventArgs e)
        {
            this.InitializeComponent();
            base.OnInit(e);
        }

        private void Page_Load(object sender, EventArgs e)
        {
            this.btnShutdown.get_Attributes().set_Item("onclick", "javascript:return confirm('此次操作将重启站点，请确认？');");
        }
    }
}

